#ifndef __VCD_DOWNLOAD_H__
#define __VCD_DOWNLOAD_H__
#include <glib.h>
#include <stdlib.h>
#include <glib.h>
#include <glib/gthread.h>
#include <glib/gmessages.h>
#include <stdio.h>
#include <string.h>

#include <curl/curl.h>

G_BEGIN_DECLS

typedef gboolean (*VCD_DOWNDOAD_CALLBACK)(gpointer res);

typedef struct network_response{
    gint64 response_code;
    gchar *memory;
    gchar *error_msg;
    gpointer data_priv;
}network_response;

typedef struct network_request_arg
{
	char url[256];
    int http_method;
    char post_fields[1280];
	long timeout;
	struct curl_slist *list;
    gpointer data_priv;
    VCD_DOWNDOAD_CALLBACK callback;//init is NULL
}network_request_arg;

struct memory_struct
{
    char *memory;
    size_t size;
};

void network_response_free(struct network_response** pp_res);

int start_download_thread(gboolean open_debug_info);
void stop_download_thread(void);
void net_req_list_add(struct network_request_arg* pt);

network_response* vcd_download_do_request_sync(struct network_request_arg *tmp);

G_END_DECLS

#endif
